﻿@using publicLibrary;
@using asMeishi.web.Models;
@using asMeishi.web.Classes;
@{
    Layout = null;
    string shopId = ViewBag.shopId as string;
}
<div class="shopBoxContent" id="commentsPanle">
    <!---评论---->


    <!--评价列表-->
    <fieldset id="commentsBar">
    <legend >已有评论 @ViewBag.num</legend>
    <!--<button type="button" id="getCommentBtn">查看10条</button>-->
    </fieldset>
    <!--评价列表 end-->                

    @foreach (var item in Model){
        comment _comment = item[0];
        user _user = item[1] as user ?? userC.guestUser;
    
        <div id="@_comment.Id.ToString()" class="comment">
            <div class="datetime _var"><span class="date">@_comment.datetime.ToString("yy-MM-dd")</span> <span class="time">@_comment.datetime.ToString("HH:mm")</span> </div>
            <div class="avatar"><img src="@(baseConfig.siteThemePath)images/userNullPic.png" /></div>
            <div class="author"><a href="#" class="_var">@_user.name</a></div>
            <div class="grads">
                @if (!string.IsNullOrWhiteSpace(@_comment.quality.ToTryString()))
                {
                <span>味道</span><span class="quality _var">@_comment.quality</span>
                <span>服务</span><span class="service _var">@_comment.service</span>
                <span>环境</span><span class="priceQuality _var">@_comment.priceQuality</span>
            
                }
                @if (!string.IsNullOrWhiteSpace(@_comment.cost.ToTryString())){
                <span><span>人均花费 : </span><span class="_var">@_comment.cost</span></span>
                }
            </div>

            <div><span class="content _var">@_comment.content</span></div>
            <div class="item"><span>推荐: </span>@_comment.food.SplitToHTMLbyCode("<A href='/shop/FindFood/"+@shopId+"?name=_var_'>_var_</A>")</div>

@*            @if(powerCheck.recordEditDel(@_comment.userId.ToString(),userC.loginUser)){
                <button class="del">modify</button><button class="del">del</button>
            }*@
        </div>
    }
    @Html.Partial("p_paging", ViewBag.pageInfo as Object)
    @using (Html.BeginForm("addCommentAndFood", "shop", FormMethod.Post, new { id = "addCommentAndFood" }))
    {
    @Html.Hidden("Id", shopId);
    @Html.Partial("p_addComment", new commentC().createDefault(userC.loginUser))
    @Html.Partial("p_addfood")

    <button type="button" class="btn btn-big" style="margin-left:500px; margin-top:5px;" onclick="commentSubmit()">提交</button>
}

</div>
<script>
    initComment();
    function commentSubmit() {
        var vir = true;
        var nullStr="暂不评分"
        var priceQuality_input = document.getElementById('priceQuality');
        var service_input = document.getElementById('service');
        var quality_input = document.getElementById('quality');

        if (priceQuality_input.options[priceQuality_input.selectedIndex].value == nullStr
            && service_input.options[service_input.selectedIndex].value == nullStr
            && quality_input.options[quality_input.selectedIndex].value == nullStr
        ) {
           
        }else{
            if (priceQuality_input.options[priceQuality_input.selectedIndex].value == nullStr
                || service_input.options[service_input.selectedIndex].value == nullStr
                || quality_input.options[quality_input.selectedIndex].value == nullStr
                ) {
                vir = false;
                mess = "有评分选项未打分，ps:如果不评分，请都选为 " + nullStr;
            }
        }

        if (vir == true) {
            document.getElementById("addCommentAndFood").submit();
        } else {
            alert(mess);
        }

    }
</script>
